<template>
	<view class="page" style="padding-top: 104rpx;">
		<view class="header">
			<image @click="back" class="back" src="../../static/tian/back.png" mode=""></image>
			<view class="text">{{$t('first.title59')}}</view>
			<view></view>
		</view>
		<view class="ArbitrageAIList_down">
			<view class="item" v-if="detailist.length > 0" v-for="(item,index) in detailist">
				<view class="itemheader" style="margin-bottom: 18rpx;justify-content: flex-start;">
					<view class="left">{{item.value}}</view>
					<view class="left" style="margin-left: 10rpx;">{{item.code}}</view>
				</view>
				<view class="itemheader">
					<view class="left1">
						{{item.created_at}}
					</view>
				</view>
			</view>
			<u-loadmore
				v-if="detailist.length > 0"
				:status="loadmorestatus" 
				:loading-text="$t('first.title120')" 
				:loadmore-text="$t('first.title119')" 
				:nomore-text="$t('first.title121')"
				marginTop="18px"
			/>
			<view class="nodata" v-if="detailist.length == 0">
				<image class="icon" src="../../static/tian/zanwu.png" mode=""></image>
				<view class="nodata_text">{{$t('first.title44')}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {domain} from '../../config/domain.js'
	export default{
		data(){
			return{
				detailist:[],
				page:1,
				lastpage:1,
				loadmorestatus:'loadmore'
			}
		},
		onLoad() {
			this.userinfo= uni.getStorageSync('userinfo');
			this.getlist()
		},
		onReachBottom() {
			this.page++;
			if(this.page <= this.lastpage){
				this.loadmorestatus = 'loading'
				var url= domain + 'api/dao_profit?page=' + this.page;
				var mytype='get';
				uni.request({
					url,
					method: mytype,
					header: {
						'content-type': 'application/x-www-form-urlencoded' ,//自定义请求头信息
						'Lang':uni.getStorageSync('lang'),
						'AUTHORIZATION':this.userinfo.token,
					},
					success: res => {
						this.loadmorestatus = 'loadmore'
						if(res.data.code==0){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							}); 
						}else{
							this.detailist=[...this.detailist,...res.data.data.data]
						}
					},
					fail: (err) => {
						this.loadmorestatus = 'loadmore'
						console.log(err)
					},
					complete: () => {
						this.loadmorestatus = 'loadmore'
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
					}
				});
			}else{
				this.loadmorestatus = 'nomore'
			}
		},
		methods:{
			getlist(){
				var url= domain + 'api/dao_profit?page=' + this.page;
				var mytype='get';
				uni.request({
					url,
					method: mytype,
					header: {
						'content-type': 'application/x-www-form-urlencoded' ,//自定义请求头信息
						'Lang':uni.getStorageSync('lang'),
						'AUTHORIZATION':this.userinfo.token,
					},
					success: res => {
						if(res.data.code==0){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							}); 
						}else{
							this.detailist=res.data.data.data
							this.lastpage = res.data.data.last_page
							if(this.lastpage == 1){
								this.loadmorestatus = 'nomore'
							}
						}
					},
					fail: (err) => {
						console.log(err)
					},
					complete: () => {
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
					}
				});
			},
			back(){
				uni.navigateBack()
			},
		}
	}
</script>

<style scoped>
	*{
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}
	.page{
		width: 100%;
		height: 100%;
		min-height: 100vh;
		background-color: #ecf0f5;
	}
	.header{
		width: 100%;
		height: 104rpx;
		padding: 20rpx;
		position: fixed;
		background-color: #ecf0f5;
		display: flex;
		top: 0;
		left: 0;
		align-items: center;
		justify-content: space-between;
		z-index: 999;
	}
	.back{
		width: 48rpx;
		height: 48rpx;
	}
	.header .text{
		font-size: 36rpx;
		font-family: PingFangSC-Medium,PingFang SC;
		font-weight: 600;
		color: #222;
	}
	.ArbitrageAIList_down{
		width: 100%;
		padding: 40rpx;
		padding-top: 0;
		box-sizing: border-box;
	}
	.nodata{
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}
	.nodata .icon{
		width: 420rpx;
		height: 366rpx;
	}
	.nodata_text{
		font-size: 28rpx;
		font-family: PingFangSC-Regular,PingFang SC;
		font-weight: 400;
		color: #9394bc;
	}
	.item{
		width: 100%;
		height: 146rpx;
		background: #fff;
		box-shadow: 0 0.18667rem 0.42667rem 0 rgb(0 0 0 / 8%);
		border-radius: 32rpx;
		margin-top: 40rpx;
		padding: 36rpx;
		box-sizing: border-box;
	}
	.itemheader{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.itemheader .left{
		font-size: 32rpx;
		font-weight: bold;
		color: #323233;
	}
	.itemheader .left1{
		font-size: 24rpx;
		color: #858587;
	}
	.itemheader .right{
		font-size: 28rpx;
		color: #ffb40f;
	}
	.itemheader .right1{
		font-size: 24rpx;
		color: #858587;
	}
	.itemheader .right2{
		font-size: 24rpx;
		color: #00aa00;
	}
</style>